package com.nhjf.mobile.controller;

import java.io.IOException;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;


/**
 * @author lixx
 * 
 */
public class BaseController {

	/**
	 * 自动将yyyy-MM-dd格式的参数转换成Date型参数
	 * 
	 * @param binder
	 */
//	@InitBinder
//	public void initBinder(WebDataBinder binder) {
//		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
//		dateFormat.setLenient(false);
//		binder.registerCustomEditor(Date.class, new CustomDateEditor(
//				dateFormat, true));
//	}

	/**
	 * 获得当前登陆用户信息
	 * 
	 * @return
	 */
//	public MemberDto getSessionMember(HttpServletRequest request) {
//		try {
//			Object obj = request.getSession().getAttribute("member");
//			if (obj != null) {
//				MemberDto member = (MemberDto) obj;
//				return member;
//			}
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//		return null;
//	}
	
	/**
	 * 将用户信息放入session
	 * @param request
	 * @param member
	 */
//	public void createSessionMember(HttpServletRequest request,MemberDto member){
//		request.getSession().setAttribute("member", member);
//	}

	/**
	 * 获得当前登陆用户ID
	 * 
	 * @return
	 */
//	public Long getSessionMemberID(HttpServletRequest request) {
//		try {
//			Object obj = request.getSession().getAttribute("member");
//			if (obj != null) {
//				MemberDto member = (MemberDto) obj;
//				return member.getId();
//			}
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//		return null;
//	}

	/**
	 * 获得明珠会员卡号
	 * 
	 * @param request
	 * @return
	 */
//	public String getSessionMemberNo(HttpServletRequest request) {
//		try {
//			Object obj = request.getSession().getAttribute("member");
//			if (obj != null) {
//				MemberDto member = (MemberDto) obj;
//				return member.getMemberNo();
//			}
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//
//		return null;
//	}

}
